/*
 * @Description: 
 * @Version: 0.0.0
 * @Autor: 源
 * @Date: 2022-10-20 15:59:55
 * @LastEditors: 源
 * @LastEditTime: 2022-11-03 09:40:56
 * @FilePath: \pnpm-v3-ts-ui\docs\.vitepress\route\index.ts
 */
import Nav from './nav.json';
import Components from './components.json';
import Guide from './guide.json';
import Build from './build.json';
import Gathers from './gathers.json';

/**
 * 顶部导航
 */
export const nav = Nav
/**
 * 
 * @param data 
 * @returns 
 */
const pathJoin = (data) => {
  var keys = Object.keys(data);
  let _sidebar = {};
  keys.map((key) => _sidebar[key] = mapPrefix(data[key], key))
  return _sidebar;
}
/**
 * 根据对象key补全路径
 * @param data 对象下的数组
 * @param prefix 对象key为前缀
 * @returns 
 */
const mapPrefix = (data, prefix) => {
  var newData = data.map((e) => {
    if (e.items && e.items.length > 0) {
      mapPrefix(e.items, prefix)
    } else {
      if (e.link) {
        e.link = `${prefix}${e.link}`
      }
    }
    return { ...e }
  })
  return newData
}
var sidebars = { ...Components, ...Guide,...Build,...Gathers }
//侧边栏
export const sidebar = pathJoin(sidebars)

